66f3c0f415d4473cc34a9787f611fe3d2bc28d9e,xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-api/src/main/java/org/xwiki/security/authorization/cache/internal/DefaultSecurityCacheLoader.java,DefaultSecurityCacheLoader,loadUserEntry,#UserSecurityReference#SecurityReference#SecurityReference#,205

Before Change


            }
            // Load shadow of the user into the cache
            localGroups = new HashSet<GroupSecurityReference>();
            loadUserEntry(user, userWiki, entityWiki, localGroups);
            groups.addAll(localGroups);
        }

After Change


        throws ParentEntryEvictedException, ConflictingInsertionException, AuthorizationException
    {
        // First, we try to get the groups of the user from the cache
        Collection<GroupSecurityReference> groups = securityCache.getGroupsFor(user, entityWiki); 
        if (groups != null) {
            // Since we have then in the cache, it means that the entry is already loaded
            return groups;
        }
        
        // Otherwise we have to load the entry
        groups = new HashSet<>();
        
        // If the user is global and we are looking for rules inside a subwiki
        if (entityWiki != null) {
            // Optim: We know we will have to load at least the rules concerning the local groups of the user, but we 
            // can try to get the global groups of that user, meaning that we would not have to load the rules
            // concerning them via the bridge.
            Collection<GroupSecurityReference> globalGroups = securityCache.getGroupsFor(user, null);
            if (globalGroups == null) {
                // No luck, the cache has no information about the global groups, so we will load them too
                globalGroups = new HashSet<>();
                loadUserEntry(user, userWiki, null, globalGroups);
            }
            groups.addAll(globalGroups);

            // Now we load the rules concerning the shadows of the global groups in the subwiki
            for (GroupSecurityReference group : globalGroups) {
                Collection<GroupSecurityReference> localGroups = new HashSet<>();
                loadUserEntry(group, userWiki, entityWiki, localGroups);
                groups.addAll(localGroups);
            }
            
            // And finally we load the rules concerning the shadow of the user
            Collection<GroupSecurityReference> localGroups = new HashSet<>();
            loadUserEntry(user, userWiki, entityWiki, localGroups);
            groups.addAll(localGroups);
            
        } else {